<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>借用构造函数继承</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        ul {
            list-style: none;
        }
    </style>
</head>
<body>
    
    <script type="text/javascript">
        /* 
        call/apply/bind
        */

        function Animal(type,age){
            this.type = type;
            this.age = age;
            this.friends = [];
        }

        function Cat(name, type, age){
            Animal.call(this, type, age);
            this.name = name;
        }

        // Cat.prototype = Animal.prototype;

        var tom = new Cat("Tom", "美洲猫", 2);
        var blue = new Cat("Blue", "亚洲猫", 5);

        blue.friends.push("Red Rabbit");
        tom.friends.push("Jerry");
        console.log(tom.friends);
        console.log(blue.friends);

        // 优点：可以让子类构造函数实例自定义父类构造函数参数，同时实现了父类构造函数属性的私有属性不共享

        // 问题：原型上的方法未实现继承
    </script>
</body>
</html>